package com.ruoyi.system.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ZtfStudyRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.time.LocalDate;

@RestController
@RequestMapping("app/system/record")
@Api(tags = "app我的课堂记录相关接口")
public class ZtfStudyRecordController extends BaseController {
    @Autowired
    private ZtfStudyRecordService ztfStudyRecordService;

    /**
     * 统计观看时长
     * @param begin
     * @param end
     * @return
     */
    @ApiOperation("观看时长统计")
    @GetMapping("/report")
    public AjaxResult viewStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                     @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) throws ParseException {
        //获取用户id
         Long userId = SecurityUtils.getUserId();
        return success(ztfStudyRecordService.getviewStatistics(begin,end,userId));
    }
}
